/*
 * author zby
 * 首页初始化数据
 */

(function (document, window, $, Utils) {
    'use strict';
    var vm = {};
    $(function () {
        var fns = {
            search: function (me) {
                Utils.getSimpleJson({
                    url: "/manager/articleCatalog/page",
                    params: Utils.getSearchParams(me),
                    fn: function (data) {
                        vm.articles = data;
                    }
                })
            },
            del: function (cid) {
                Utils.delete({
                    url: "/manager/articleCatalog",
                    id: cid
                })
            },
            add: function () {
                var obj = {
                    pageType: "add"
                };
                window.location.href = "articleListMgt_add_edit.html?" + Utils.formatParams(obj);
            },
            edit: function (cid) {
                var obj = {
                    pageType: "edit",
                    id: cid
                };
                window.location.href = "articleListMgt_add_edit.html?" + Utils.formatParams(obj);
            },
            browseDetails: function (cid) {
                var obj = {
                    pageType: 'browseDetails',
                    id: cid
                };
                window.location.href = "browserArticleListMgt.html?" + Utils.formatParams(obj);
            },
            comment: function (cid) {
                var obj = {
                    pageType:'comment',
                    id: cid
                };
                window.location.href = "commentListMgt.html?" + Utils.formatParams(obj);
            }
        };
        window.fns = fns;
        init();
    });

    //入口方法
    function init() {
        vm = new Vue({
            el: '#tableInfo',
            data: {
                enums: {},
                articles: {}
            },
        })
        fns.search();
    }


})(document, window, jQuery, Utils);